<?php
class TrackController extends BackendApplicationController
{
	public $layout = 'application.modules.bill.views.layouts.global';
	public function actionIndex()
	{
		$id = Yii::app()->request->getParam('id', 0);
		if(isset($_POST['SearchBill'])){
			$amBill = $_POST['SearchBill']['bill_code'];
			$id = Yii::app()->db->createCommand("select id from bill where am_bill='$amBill'")->queryScalar();
			if(!$id){
				Yii::app()->user->setState('msg',"Không tìm thấy Bill nào có mã là: ".$amBill);
			}else{
				Yii::app()->user->setState('msg',"");
			}
		}
		if($id>0){
			$model = $this->loadModel($id, 'BackendBillModel');
		}else{
			$model = null;
		}
		$this->render('index', array(
				'model' => $model,
		));
	}
}